package tankattack.sprites;

import gamepack.*;
import java.util.Vector;

/** @author Somanath
	@version 1.1
*/

interface ExplosionType { public int BIG=0,MEDIUM=1,SMALL=2;  }

// Dependency : None

public class Explosion extends Sprite implements ExplosionType {

    public static Resource r = ResourceLoader.getResource("tankattack.sprites.Explosion");

    int counter=0;
	static int zorder = r.getValueAsInt("zorder");	

//  <Data name="spawnformat"> x=%d:0,y=%d:0,type=%d:0:(0-BIG,1-MEDIUM,2-SMALL) </Data>	
	public Explosion() {// SpawnFormat: x=%d,y=%d,type=%d
		res = r;	         // point to the Explosion resouces img/sound etc
		setZOrder( zorder );		 //20
		WaveEngine.play(r.sound[type]);
		startSprite();
	}

	public void run() {
			switch( state) {
				case NORMAL:	normal();	 break;
				case DEAD:      stopSprite(); break;
			}
	}

	public void normal() {
		curFrame = counter;
		counter++;
		if( counter >= res.img[type].length) { setState(DEAD);  }
	}
}